package com.action.comet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.comet.service.CometService;

@Controller
public class CometAction {
    
	//@Autowired
	private CometService cometService;
	
	@RequestMapping(value="room")
	public ModelAndView index(){
		return new ModelAndView("comet/Room");
	}
	
	@RequestMapping(value="receive")
	public void receive(HttpServletRequest request,HttpServletResponse response){
		
		String userID = request.getParameter("userID");
		String msg = request.getParameter("msg");
		String message = "<br/>"+userID+"说:"+msg+"<br/>";
		cometService.sendToAll(userID,message);
		
	}
	
}
